﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FrmHotel
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }
        private void FrmMain_Load(object sender, EventArgs e)
        {
            toolStripButton1.Image = imageList1.Images[0];
            toolStripButton2.Image = imageList1.Images[9];
            toolStripButton3.Image = imageList1.Images[7];
            toolStripButton4.Image = imageList1.Images[5];
            toolStripButton5.Image = imageList1.Images[3];
            toolStripButton10.Image = imageList1.Images[11];
            toolStripButton6.Image = imageList1.Images[14];
            toolStripButton11.Image = imageList1.Images[16];
            toolStripButton12.Image = imageList1.Images[18];
            toolStripButton7.Image = imageList1.Images[20];
            toolStripButton8.Image = imageList1.Images[22];
            BoinListView();
            State();

        }
        public void yuojian()
        {
           
        }
        public void State()
        {
            string o = DBHelper.SelectOne(string.Format("select count(1) from roominfo where Rmstate=1")).ToString();
            this.lbl_12.Text = o;
            string o1 = DBHelper.SelectOne(string.Format("select count(1) from roominfo where Rmstate=2")).ToString();
            this.lbl_13.Text = o1;
            string o2 = DBHelper.SelectOne(string.Format("select count(1) from roominfo where Rmstate=3")).ToString();
            this.lbl_14.Text = o2;
            string o3 = DBHelper.SelectOne(string.Format("select count(1) from roominfo where Rmstate=4")).ToString();
            this.lbl_15.Text = o3;
            string sql = DBHelper.SelectOne("select count(1) from roominfo ").ToString();
            this.label7.Text = sql;
        }

        private void toolStripButton1_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton1.Image = imageList1.Images[1];
            toolStripButton1.ForeColor = Color.FromArgb(232, 164, 70);
        }
        private void toolStripButton1_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton1.Image = imageList1.Images[0];
            toolStripButton1.ForeColor = Color.FromArgb(0, 0, 0);
        }
        private void toolStripButton2_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton2.Image = imageList1.Images[8];
            toolStripButton2.ForeColor = Color.FromArgb(232, 164, 70);
        }
        private void toolStripButton2_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton2.Image = imageList1.Images[9];
            toolStripButton2.ForeColor = Color.FromArgb(0, 0, 0);
        }
        private void toolStripButton3_MouseEnter_1(object sender, EventArgs e)
        {
            toolStripButton3.Image = imageList1.Images[6];
            toolStripButton3.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton3_MouseLeave_1(object sender, EventArgs e)
        {
            toolStripButton3.Image = imageList1.Images[7];
            toolStripButton3.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void toolStripButton4_MouseEnter_1(object sender, EventArgs e)
        {
            toolStripButton4.Image = imageList1.Images[4];
            toolStripButton4.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton4_MouseLeave_1(object sender, EventArgs e)
        {
            toolStripButton4.Image = imageList1.Images[5];
            toolStripButton4.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void toolStripButton10_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton10.Image = imageList1.Images[10];
            toolStripButton10.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton10_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton10.Image = imageList1.Images[11];
            toolStripButton10.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void toolStripButton5_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton5.Image = imageList1.Images[2];
            toolStripButton5.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton5_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton5.Image = imageList1.Images[3];
            toolStripButton5.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void toolStripButton6_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton6.Image = imageList1.Images[12];
            toolStripButton6.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton6_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton6.Image = imageList1.Images[14];
            toolStripButton6.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void button1_MouseLeave(object sender, EventArgs e)
        {
            this.button1.BackColor = Color.FromArgb(187, 227, 229);
        }

        private void button2_MouseLeave(object sender, EventArgs e)
        {
            this.button2.BackColor = Color.FromArgb(187, 227, 229);
        }

        private void button3_MouseDown(object sender, MouseEventArgs e)
        {
            this.button3.BackColor = Color.FromArgb(88, 149, 153);
        }

        private void button3_MouseLeave(object sender, EventArgs e)
        {
            this.button3.BackColor = Color.FromArgb(187, 227, 229);
        }

        private void button4_MouseDown(object sender, MouseEventArgs e)
        {
            this.button4.BackColor = Color.FromArgb(88, 149, 153);
        }

        private void button4_MouseLeave(object sender, EventArgs e)
        {
            this.button4.BackColor = Color.FromArgb(187, 227, 229);
        }   

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.label1.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            
        }
        
        public void BoinListView()
        {
       
            this.listView1.Items.Clear();
            string sql = "select r.RmId,o.RoomName,o.RoomMoney,s.StName from RoomInfo r,Room o,RmState s  where s.StId=r.RmState and r.RmRoom=o.RoomId ";
             ListViewItem item=null;
            SqlDataReader reader = DBHelper.SelectMore(sql);
            while (reader.Read())
            {
                item = new ListViewItem(reader["RmId"].ToString());
                //item.BackColor = Color.Red;
                item.SubItems.Add(reader["RoomName"].ToString());
                item.SubItems.Add(reader["RoomMoney"].ToString());
                item.SubItems.Add(reader["StName"].ToString());

                if (reader["StName"].Equals("空闲"))
                {
                    item.BackColor = Color.FromArgb(91, 188, 32);
                  
                    //this.登记入住ToolStripMenuItem1.ForeColor = Color.FromArgb(129, 129, 129);
                    //this.预定房间ToolStripMenuItem1.ForeColor = Color.FromArgb(129, 129, 129);
                    //this.打扫房间ToolStripMenuItem.ForeColor = Color.FromArgb(129, 129, 129);
                    //this.续住办理ToolStripMenuItem1.ForeColor = Color.FromArgb(129, 129, 129);
                    //this.更换房间ToolStripMenuItem1.ForeColor = Color.FromArgb(129, 129, 129);
                    //this.房间结账ToolStripMenuItem.ForeColor = Color.FromArgb(129, 129, 129);
                    //this.添加消费ToolStripMenuItem1.ForeColor = Color.FromArgb(129, 129, 129);
                }
                else if (reader["StName"].Equals("预住"))
                {
                    item.BackColor = Color.FromArgb(250, 106, 106);

                }
                else if (reader["StName"].Equals("已住"))
                {
                    item.BackColor = Color.FromArgb(232, 164, 70);
                    
                }
                else if (reader["StName"].Equals("脏房"))
                {
                    item.BackColor = Color.FromArgb(128, 128, 128);
                   
                }
                
                listView1.Items.Add(item);
            }
            reader.Close();
            //DateTime tt = DateTime.Now;//当前系统日期 
            //DateTime yvdi = DateTime.Now;//当前系统日期 

            //string sql1 = string.Format("select RvCut from ResvInfo ");
            //SqlDataReader re = DBHelper.SelectMore(sql1);
            //while (re.Read())
            //{
            //    yvdi = Convert.ToDateTime(re["RvCut"]);
            //}
            //re.Close();

            //if (tt.Day == yvdi.Day&&tt.Hour > yvdi.Hour)
            //{
            //    string sql2 = string.Format("update RoomInfo set RmState=2 where ");
            //    int gg1 = DBHelper.ExecuteUpdate(sql2);
            //}
            //if (tt.Day > yvdi.Day)
            //{
            //    string sql3 = string.Format("update RoomInfo set RmState=1  ");
            //    int ggg = DBHelper.ExecuteUpdate(sql3);
            //}

        }
        private void listView1_Click(object sender, EventArgs e)
        {
            Qkong();
        }
        public void Qkong()
        {
            this.lbl_1.Text = this.lbl_2.Text = this.lbl_5.Text = this.lbl_3.Text = this.lbl_4.Text = this.lbl_6.Text = this.lbl_7.Text = this.lbl_8.Text = this.lbl_9.Text = this.lbl_10.Text = this.lbl_11.Text = string.Empty;
            if (this.listView1.SelectedItems.Count <= 0)
            {
                return;
            }
            ListViewItem item = this.listView1.SelectedItems[0];
            int id = Convert.ToInt32(item.Text);
            string o = DBHelper.SelectOne(string.Format("select rmstate from roominfo r,Room o where r.RmRoom=o.RoomId and r.RmId=" + id)).ToString();
            string sql = "select r.RmId,o.RoomName,o.RoomMoney  from RoomInfo r,Room o where r.RmRoom=o.RoomId and r.RmId=" + id;
            if (o.Equals("3"))
            {
                sql = string.Format(@"select r.RmId,o.RoomName,c.CeName,c.CeAge,o.RoomMoney,h.CKCin,h.CKYong,c.CeCut,h.CKXfei,c.CePhone,v.TypeName from
                    RoomInfo r,Room o,CetaeInfo c,checkInfo h,VipType v where r.RmRoom=o.RoomId and c.CeFangHao=r.RmId 
                    and h.Ckname=c.CeId and c.CeXing=v.VipId and r.rmid={0}", id);
            }
            SqlDataReader reader = DBHelper.SelectMore(sql);
            while (reader.Read())
            {
                this.lbl_1.Text = reader["RmId"].ToString();
                this.lbl_2.Text = reader["RoomName"].ToString();
                this.lbl_5.Text = reader["RoomMoney"].ToString();
                if (o.Equals("3"))
                {
                    this.lbl_3.Text = reader["CeName"].ToString();
                    this.lbl_4.Text = reader["CeAge"].ToString();
                    this.lbl_6.Text = reader["CKCin"].ToString();
                    this.lbl_7.Text = reader["CeCut"].ToString();
                    this.lbl_8.Text = reader["CKYong"].ToString();
                    this.lbl_9.Text = reader["CKXfei"].ToString();
                    this.lbl_10.Text = reader["CePhone"].ToString();
                    this.lbl_11.Text = reader["TypeName"].ToString();
                }
            }
            reader.Close();
        }
        private void button2_MouseDown(object sender, MouseEventArgs e)
        {
            this.button2.BackColor = Color.FromArgb(88, 149, 153);
        }

        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            this.button1.BackColor = Color.FromArgb(88, 149, 153);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.listView1.Items.Clear();
            string sql = "select r.RmId,o.RoomName,o.RoomMoney,s.StName from RoomInfo r,Room o,RmState s  where s.StId=r.RmState and r.RmRoom=1 and r.RmRoom=o.RoomId ";

            SqlDataReader reader = DBHelper.SelectMore(sql);
            while (reader.Read())
            {
                ListViewItem item = new ListViewItem(reader["RmId"].ToString());
                //item.BackColor = Color.Red;
                item.SubItems.Add(reader["RoomName"].ToString());

                item.SubItems.Add(reader["RoomMoney"].ToString());
                item.SubItems.Add(reader["StName"].ToString());
                if (reader["StName"].Equals("空闲"))
                {
                    item.BackColor = Color.FromArgb(91, 188, 32);
                }
                else if (reader["StName"].Equals("预住"))
                {
                    item.BackColor = Color.FromArgb(250, 106, 106);
                  
                }
                else if (reader["StName"].Equals("已住"))
                {
                    item.BackColor = Color.FromArgb(232, 164, 70);
                }
                else if (reader["StName"].Equals("脏房"))
                {
                    item.BackColor = Color.FromArgb(128, 128, 128);
                }
                listView1.Items.Add(item);
            }
            reader.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BoinListView();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.listView1.Items.Clear();
            string sql = "select r.RmId,o.RoomName,o.RoomMoney,s.StName from RoomInfo r,Room o,RmState s  where s.StId=r.RmState and r.RmRoom=2 and r.RmRoom=o.RoomId ";

            SqlDataReader reader = DBHelper.SelectMore(sql);
            while (reader.Read())
            {
                ListViewItem item = new ListViewItem(reader["RmId"].ToString());
                //item.BackColor = Color.Red;
                item.SubItems.Add(reader["RoomName"].ToString());

                item.SubItems.Add(reader["RoomMoney"].ToString());
                item.SubItems.Add(reader["StName"].ToString());
                if (reader["StName"].Equals("空闲"))
                {
                    item.BackColor = Color.FromArgb(91, 188, 32);
                }
                else if (reader["StName"].Equals("预住"))
                {
                    item.BackColor = Color.FromArgb(250, 106, 106);
                }
                else if (reader["StName"].Equals("已住"))
                {
                    item.BackColor = Color.FromArgb(232, 164, 70);
                }
                else if (reader["StName"].Equals("脏房"))
                {
                    item.BackColor = Color.FromArgb(128, 128, 128);
                }
                listView1.Items.Add(item);
            }
            reader.Close();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.listView1.Items.Clear();
            string sql = "select r.RmId,o.RoomName,o.RoomMoney,s.StName from RoomInfo r,Room o,RmState s  where s.StId=r.RmState and r.RmRoom=3 and r.RmRoom=o.RoomId ";

            SqlDataReader reader = DBHelper.SelectMore(sql);
            while (reader.Read())
            {
                ListViewItem item = new ListViewItem(reader["RmId"].ToString());
                //item.BackColor = Color.Red;
                item.SubItems.Add(reader["RoomName"].ToString());

                item.SubItems.Add(reader["RoomMoney"].ToString());
                item.SubItems.Add(reader["StName"].ToString());
                if (reader["StName"].Equals("空闲"))
                {
                    item.BackColor = Color.FromArgb(91, 188, 32);
                }
                else if (reader["StName"].Equals("预住"))
                {
                    item.BackColor = Color.FromArgb(250, 106, 106);
                }
                else if (reader["StName"].Equals("已住"))
                {
                    item.BackColor = Color.FromArgb(232, 164, 70);
                }
                else if (reader["StName"].Equals("脏房"))
                {
                    item.BackColor = Color.FromArgb(128, 128, 128);
                }
                listView1.Items.Add(item);
            }
            reader.Close();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请至少选择一间房间入住！", "提示信息！");
                return;
            }
            ListViewItem item = this.listView1.SelectedItems[0];
            int id = Convert.ToInt32(item.Text);
            string sql = "select * from RoomInfo where RmId=" + id;
            SqlDataReader reader = DBHelper.SelectMore(sql);
            int zt = -1;
            if (reader.Read())
            {
                 zt = Convert.ToInt32(reader["RmState"]);
            }
            reader.Close();
            if (zt==1)
            {
                //登记入住
                FrmRuzhu fr = new FrmRuzhu();
                fr.id = id;
                fr.ShowDialog();
                BoinListView();//更新数据
                State();
                Qkong();
            }
            else if (zt==3)
            {
                MessageBox.Show("此房已被入住,不能再次入住！", "提示信息！");
                return;
            }
            else if (zt == 2)
            {
                MessageBox.Show("此房已被预定,不能再次预定！", "提示信息！");
                return;
            }
            else if (zt == 4)
            {
                MessageBox.Show("此房是脏房,不能登记入住！", "提示信息！");
                return;
            }
        }

        private void toolStripButton11_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton11.Image = imageList1.Images[15];
            toolStripButton11.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton11_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton11.Image = imageList1.Images[16];
            toolStripButton11.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void toolStripButton12_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton12.Image = imageList1.Images[17];
            toolStripButton12.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton12_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton12.Image = imageList1.Images[18];
            toolStripButton12.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void toolStripButton7_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton7.Image = imageList1.Images[19];
            toolStripButton7.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton7_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton7.Image = imageList1.Images[20];
            toolStripButton7.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请至少选择一间房间预定！", "提示信息！");
                return;
            }
            ListViewItem item = this.listView1.SelectedItems[0];
            int id = Convert.ToInt32(item.Text);
            string sql = "select * from RoomInfo where RmId=" + id;
            SqlDataReader reader = DBHelper.SelectMore(sql);
            int zt = -1;
            if (reader.Read())
            {
                zt = Convert.ToInt32(reader["RmState"]);
            }
            reader.Close();
            if (zt == 1)
            {
                //预定房间
                FrmYvDing fy = new FrmYvDing();
                fy.id = id;
                fy.ShowDialog();
                BoinListView();//更新数据
                State();
            }
            else if (zt == 3)
            {
                MessageBox.Show("此房已被入住,不能预定！", "提示信息！");
                return;
            }
            else if (zt == 2)
            {
                MessageBox.Show("此房已被预定,不能再次预定！", "提示信息！");
                return;
            }
            else if (zt == 4)
            {
                MessageBox.Show("此房是脏房,不能预定！", "提示信息！");
                return;
            }
        }
        public void yyzz()
        {
           
        }
        private void toolStripButton8_MouseEnter(object sender, EventArgs e)
        {
            toolStripButton8.Image = imageList1.Images[21];
            toolStripButton8.ForeColor = Color.FromArgb(232, 164, 70);
        }

        private void toolStripButton8_MouseLeave(object sender, EventArgs e)
        {
            toolStripButton8.Image = imageList1.Images[22];
            toolStripButton8.ForeColor = Color.FromArgb(0, 0, 0);
        }

        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请至少选择一间房间续住！", "提示信息！");
                return;
            }
            ListViewItem item = this.listView1.SelectedItems[0];
            int id = Convert.ToInt32(item.Text);
            string sql = "select * from RoomInfo where RmId=" + id;
            SqlDataReader reader = DBHelper.SelectMore(sql);
            int zt = -1;
            if (reader.Read())
            {
                zt = Convert.ToInt32(reader["RmState"]);
            }
            reader.Close();
            if (zt == 1)
            {
                MessageBox.Show("此房是空房,不能续住！", "提示信息！");
                return;
            }
            else if (zt == 3)
            {
               //续住办理
                FrmXvZhu fx = new FrmXvZhu();
                fx.id = id;
                fx.ShowDialog();
                State();
                Qkong();
                BoinListView();
            }
            else if (zt == 2)
            {
               //000  预住
            }
            else if (zt == 4)
            {
                MessageBox.Show("此房是脏房,不能续住！", "提示信息！");
                return;
            }
        }

        private void toolStripButton12_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请至少选择一间房间预定！", "提示信息！");
                return;
            }
            ListViewItem item = this.listView1.SelectedItems[0];
            int id = Convert.ToInt32(item.Text);
            string sql = "select * from RoomInfo where RmId=" + id;
            SqlDataReader reader = DBHelper.SelectMore(sql);
            int zt = -1;
            if (reader.Read())
            {
                zt = Convert.ToInt32(reader["RmState"]);
            }
            reader.Close();
            if (zt == 1)
            {
                MessageBox.Show("此房空房,不能更换房间！", "提示信息！");
                return;
            }
            else if (zt == 3)
            {
                //更换房间
                FrmGengHuan fg = new FrmGengHuan();
                fg.id = id;
                fg.ShowDialog();
                State();
                Qkong();
                BoinListView();
            }
            else if (zt == 2)
            {
                // 预定
            }
            else if (zt == 4)
            {
                MessageBox.Show("此房是脏空房,不能更换房间！", "提示信息！");
                return;
            }
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            FrmSuoDing fs = new FrmSuoDing();
            fs.ShowDialog();
        }

        private void 打扫房间ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请至少选择一间房间预定！", "提示信息！");
                return;
            }
            ListViewItem item = this.listView1.SelectedItems[0];
            int id = Convert.ToInt32(item.Text);
            string sql = "select * from RoomInfo where RmId=" + id;
            SqlDataReader reader = DBHelper.SelectMore(sql);
            int zt = -1;
            if (reader.Read())
            {
                zt = Convert.ToInt32(reader["RmState"]);
            }
            reader.Close();
            if (zt == 1)
            {
                MessageBox.Show("此房空房,不能更换房间！", "提示信息！");
                return;
            }
            else if (zt == 3)
            {
                MessageBox.Show("宾客在住房,不能打扫房间！", "提示信息！");
                return;
            }
            else if (zt == 2)
            {
                MessageBox.Show("预住期间,不能打扫房间！", "提示信息！");
                return;
            }
            else if (zt == 4)
            {
                FrmDaSaoFj fd = new FrmDaSaoFj();
                fd.id = id;
                fd.ShowDialog();
                //更新数据
                State();
                Qkong();
                BoinListView();
            }
        }

        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            //if (this.listView1.SelectedItems.Count <= 0)
            //{
            //    return;
            //}
            // if (listView1.SelectedItems[0].BackColor== Color.FromArgb(91, 188, 32))
            //{
            //    this.contextMenuStrip1.Items[2].Enabled = false;
            //    this.contextMenuStrip1.Items[3].Enabled = false;
            //    this.contextMenuStrip1.Items[4].Enabled = false;
            //    this.contextMenuStrip1.Items[5].Enabled = false;
            //    this.contextMenuStrip1.Items[6].Enabled = false;
            //}
            // else if (listView1.SelectedItems[0].BackColor == Color.FromArgb(232, 164, 70))
            // {
            //     this.contextMenuStrip1.Items[0].Enabled = false;
            //     this.contextMenuStrip1.Items[1].Enabled = false;
            //     this.contextMenuStrip1.Items[6].Enabled = false;
            // }
            // else if (listView1.SelectedItems[0].BackColor == Color.FromArgb(243, 208, 176))
            // {
            //     this.contextMenuStrip1.Items[0].Enabled = false;
            //     this.contextMenuStrip1.Items[1].Enabled = false;
            //     this.contextMenuStrip1.Items[6].Enabled = false;
            //     this.contextMenuStrip1.Items[2].Enabled = false;
            //     this.contextMenuStrip1.Items[3].Enabled = false;
            //     this.contextMenuStrip1.Items[4].Enabled = false;
            // } else if (listView1.SelectedItems[0].BackColor == Color.FromArgb(128, 128, 128))
            // {
            //     this.contextMenuStrip1.Items[0].Enabled = false;
            //     this.contextMenuStrip1.Items[1].Enabled = false;
            //     this.contextMenuStrip1.Items[2].Enabled = false;
            //     this.contextMenuStrip1.Items[3].Enabled = false;
            //     this.contextMenuStrip1.Items[4].Enabled = false;
            //     this.contextMenuStrip1.Items[5].Enabled = false;
            // }

        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请至少选择一间房间预定！", "提示信息！");
                return;
            }
            ListViewItem item = this.listView1.SelectedItems[0];
            int id = Convert.ToInt32(item.Text);
            string sql = "select * from RoomInfo where RmId=" + id;
            SqlDataReader reader = DBHelper.SelectMore(sql);
            int zt = -1;
            if (reader.Read())
            {
                zt = Convert.ToInt32(reader["RmState"]);
            }
            reader.Close();
            if (zt == 1)
            {
                MessageBox.Show("此房空房,不能添加消费！", "提示信息！");
                return;
            }
            else if (zt == 3)
            {
                //添加消费
                FrmTianJiaXF xf = new FrmTianJiaXF();
                xf.id = id;
                xf.ShowDialog();
            }
            else if (zt == 2)
            {
                MessageBox.Show("预住期间,不能添加消费！", "提示信息！");
                return;
            }
            else if (zt == 4)
            {
               MessageBox.Show("此房是脏空房,不能添加消费！", "提示信息！");
                return;
            }
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {

            BoinListView();
            State();
            Qkong();
        }
        
    }
}
